package com.newly.api.sys.feign;

import com.newly.common.base.constants.AuthConstant;
import com.newly.common.base.constants.ServerUriConstant;
import com.newly.common.base.entity.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @program: newly-parent
 * @remark: 权限实体api接口
 * @author: guan
 * @create: 2022-01-13 18:11
 */
@Api(tags = "权限实体")
@FeignClient(path = ServerUriConstant.NEWLY_SYS_AUTH_ENTITY, name = ServerUriConstant.NEWLY_SYS_SERVICE_NAME)
public interface AuthEntityClient {

    @ApiOperation("查询权限实体类型")
    @GetMapping("/queryEntityTypes")
    R queryTypes();

    @ApiOperation("通过权限实体类型获取权限实体")
    @GetMapping("/queryByTypeCode")
    R queryByTypeCode(@NotNull(message = "typeCode can't be empty")
                      @RequestParam("typeCode") Integer typeCode);

    @ApiOperation("获取当前租户的所有权限实体")
    @GetMapping("/listAuthEntity")
    R listAuthEntity();

    @ApiOperation("通过角色id与类型编码获取权限实体id")
    @GetMapping("/queryIdsByRoleIdAndTypeCode")
    R queryIdsByRoleIdAndTypeCode(@NotNull(message = "roleId can't be empty") @RequestParam("roleId") Integer roleId,
                                  @NotNull(message = "typeCode can't be empty") @RequestParam("typeCode") Integer typeCode);

    @ApiOperation("通过角色id与类型编码获取权限实体id")
    @GetMapping("/queryAllIdsByRoleId")
    R queryAllIdsByRoleId(@NotNull(message = "roleId can't be empty")
                          @RequestParam("roleId") Integer roleId);

    @ApiOperation("绑定权限实体")
    @PostMapping("/bind")
    R bind(@RequestParam("entityType") AuthConstant.AuthEntityType entityType,
           @RequestParam("entityIds") List<String> entityIds);

    @ApiOperation("解绑权限实体")
    @PostMapping("/unbind")
    R unbind(@RequestParam("entityType") AuthConstant.AuthEntityType entityType,
             @RequestParam("entityIds") List<String> entityIds);

}
